/**
 * Created by chenwen on 17-5-15.
 */

var Weixin = require("../lib/Weixin");

var sendOrder = {
    body : "52pay",
    out_trade_no : "59196a43751e4615f49088bc",
    total_fee : 1,
    notify_url :"http://119.23.44.106:3005/notify/weichat",
    spbill_create_ip:"::ffff:127.0.0.1"
}
var w = new Weixin("192006250b4c09247ec02edce69f6a2d","wx8888888888888888","190000000109");

/*w.fetchPlaceOrder(sendOrder)
    .then(function(data){
        console.log("11111111111111111");
        console.log(data);
    }).catch(function(err){
        console.log(err);
    })*/



//微信验证
var str = "<xml>"+
    "<appid><![CDATA[wx2421b1c4370ec43b]]></appid>"+
    "<attach><![CDATA[支付测试]]></attach>"+
    "<bank_type><![CDATA[CFT]]></bank_type>"+
    "<fee_type><![CDATA[CNY]]></fee_type>"+
    "<is_subscribe><![CDATA[Y]]></is_subscribe>"+
    "<mch_id><![CDATA[10000100]]></mch_id>"+
    "<nonce_str><![CDATA[5d2b6c2a8db53831f7eda20af46e531c]]></nonce_str>"+
    "<openid><![CDATA[oUpF8uMEb4qRXf22hE3X68TekukE]]></openid>"+
    "<out_trade_no><![CDATA[58df6f1914d8b24060501053]]></out_trade_no>"+
    "<result_code><![CDATA[SUCCESS]]></result_code>"+
    "<return_code><![CDATA[SUCCESS]]></return_code>"+
    "<sign><![CDATA[B552ED6B279343CB493C5DD0D78AB241]]></sign>"+
    "<sub_mch_id><![CDATA[10000100]]></sub_mch_id>"+
    "<time_end><![CDATA[20140903131540]]></time_end>"+
    "<total_fee>1</total_fee>"+
    "<trade_type><![CDATA[JSAPI]]></trade_type>"+
    "<transaction_id><![CDATA[1004400740201409030005092168]]></transaction_id>"+
    "</xml>";

w.validateOrder(str).then(function(data){
    console.log("validate data");
    console.log(data);
}).catch(function(err){
        console.log("validate error");
        console.log(err);
})
